﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Mozlite.Components;

namespace Mozlite.WebUI.Mvc4.Controllers
{
    /// <summary>
    /// 首页控制器。
    /// </summary>
    public class HomeController : BaseController
    {
        /// <summary>
        /// 首页控制器。
        /// </summary>
        /// <returns>返回首页控制器。</returns>
        public override ActionResult Index()
        {
            var path = Request.Url.AbsolutePath.Trim('/', ' ');
            if(path.HasValue())
            {
                var length = 0;
                if(GSettings.FileExtension != null)
                    length = GSettings.FileExtension.Length;
                length = path.Length - length;
                path = path.Substring(0, length);
            }
            else
                path = "Index";
            var physicsPath = GetThemePath(path);
            if(System.IO.File.Exists(physicsPath + ".cshtml") || System.IO.File.Exists(physicsPath + ".vbhtml"))
                return View(path);
            return HttpNotFound();
        }
    }
}
